The goals / steps of this project are the following:
Here I will consider the rubric points individually and describe how I addressed each point in my implementation
| CRITERIA | MEETS SPECIFICATIONS | HOW I ADDRESSED THE POINT |
|---|---|---|
| Submission Files | The project submission includes all required files. | Traffic_Sign_Classifier.ipynb notebook file is part of this repository. An HTML export of the project notebook with the name report.html is part of this repository. Any additional datasets or images used for the project that are not from the German Traffic Sign Dataset is part of this repository. Writeup report as a markdown file is part of this repository |
| Dataset Summary | The submission includes a basic summary of the data set. | Please see section Data Set Summary & Exploration, and sub-sections 1. Provide a basic summary of the data set […], 2. Include an exploratory visualization of the dataset, 2.1 Frequency Distribution, 2.2 Checking for unbalanced classes, 2.3 Plot Signal Images |
| Exploratory Visualization | The submission includes an exploratory visualization on the dataset. | Please see section Data Set Summary & Exploration, and sub-sections 1. Provide a basic summary of the data set […], 2. Include an exploratory visualization of the dataset, 2.1 Frequency Distribution, 2.2 Checking for unbalanced classes, 2.3 Plot Signal Images |
| Preprocessing | The submission describes the preprocessing techniques used and why these techniques were chosen. | Please see section Design and Test a Model Architecture, and sub-sections 1. Describe how you preprocessed the image data […], 1.1. Normalization, 1.2. Conversion to YUV space |
| Model Architecture | The submission provides details of the characteristics and qualities of the architecture, including the type of model used, the number of layers, and the size of each layer. Visualizations emphasizing particular qualities of the architecture are encouraged. | Please see section Design and Test a Model Architecture, and sub-sections 2. Describe what your final model architecture looks like including model type […] |
| Model Training | The submission describes how the model was trained by discussing what optimizer was used, batch size, number of epochs and values for hyperparameters. | Please see section Design and Test a Model Architecture, and sub-sections 3. Describe how you trained your model. The discussion can include the type of optimizer, […] |
| Solution Approach | The submission describes the approach to finding a solution. Accuracy on the validation set is 0.93 or greater. | Please see section Design and Test a Model Architecture, and sub-sections 3. Describe how you trained your model. The discussion can include the type of optimizer, […] |
| Acquiring New Images | The submission includes five new German Traffic signs found on the web, and the images are visualized. Discussion is made as to particular qualities of the images or traffic signs in the images that are of interest, such as whether they would be difficult for the model to classify | Please see section Test a Model on New Images, and sub-sections 1. Choose at least five German traffic signs found on the web and provide them in the report. For each image, discuss what quality or qualities might be difficult to classify. |
| Performance on New Images | The submission documents the performance of the model when tested on the captured images. The performance on the new images is compared to the accuracy results of the test set. | Please see section Test a Model on New Images, and sub-sections 2. Discuss the model’s predictions on these new traffic signs and compare the results to predicting on the test set […] |
| Model Certainty - Softmax Probabilities | The top five softmax probabilities of the predictions on the captured images are outputted. The submission discusses how certain or uncertain the model is of its predictions. | Please see section Test a Model on New Images, and sub-sections 3. Describe how certain the model is when predicting on each of the five new images by looking at the softmax probabilities for each prediction […] |
I used numpy to calculate summary statistics of the traffic signs data set:
Here is an exploratory visualization of the data set.
We can see clearly there are classes like 2 and 1 with 5.7% of training set vs. classes like 37 and 0 with 0.51% of training set.
I used the following preprocessing pipeline:
Specifically, I used the recommended tranformation pixel <- (pixel - 128)/ 128
After normalization, as shown in P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011, all 32x32 images are converted to YUV space.
YUV encodes a color image taking human perception into account, allowing reduced bandwidth for chrominance components, thereby typically enabling transmission errors or compression artifacts to be more efficiently masked by the human perception than using a “direct” RGB-representation.
Specifically, I used skimage.color.rgb2yuv function that uses this approach for conversion from RGB.
I started with the LeNet-5 solution from the lecture and here are the main nimprovments:
| Layer | Description |
|---|---|
| Input | 32x32x3 YUV image |
| Convolution 5x5 | 1x1 stride, valid padding, outputs 28x28x6 |
| RELU | |
| Local Response Normalization | |
| Max pooling | kernel 2x2, 1x1 stride, outputs 27x27x6 |
| Convolution 5x5 | 1x1 stride, valid padding, outputs 23x23x16 |
| RELU | |
| Local Response Normalization | |
| Max pooling | kernel 2x2, 1x1 stride, outputs 22x22x16 |
| Multi-Scale Features | the output of the first stage is branched out and fed to the classifier, in addition to the output of the second stage, output 1x12118 |
| Fully connected | 12118x800 |
| RELU | |
| DROPOUT | only for training, keep probabily = 0.5 |
| Fully connected | 800x84 |
| RELU | |
| DROPOUT | only for training, keep probabily = 0.5 |
| Fully connected | 84x43, output 43 logits |
| Softmax | output 43 predicted probabilities |
To train the model, I used an optimizer that implements the Adam algorithm with learning rare set to 0.001, 30 epochs and batch size set to 128. I found out that:
My final model results were:
I was insipred by P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011 although I did not implement the same architecture. Specifically, I used only the first two convolutional layers. Also, after my experiments I decided to use
The main improvements came from
The use of dropout allows to avoid overfitting problems as I discovered that even with an higher number of epochs test accuracy don’t change (using the rule of 30); hence, I used 30 epochs although I could use 20 eopochs having same results.
I am confident my architecture can be extended to achieve >99% accuracy using more convolutional layers as shown in P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011
00 - 01 -
02 -
03 - 04 -
05 -
06 - 07 -
08 -
09 - 10 -
11 -
12 - 13 -
14 -
15 - 16 -
17 -
18 - 19 -
20 -
21 - 22 -
23 -
24 - 25 -
26 -
27 - 28 -
29 -
30 - 31 -
32 -
33 - 34 -
35 -
36 - 37 -
The model was able to achieve Accuracy of 80.0%, i.e. 28 corrected predictions out of 35 cases (3 images did not belong to any of 43 known classes and they have been added only for study the classifier behaviour with unknown signs).
Here are the results of the prediction with related comments:
The code for making predictions on my final model is located in the cell N. 22 of the Ipython notebook.
Here below you can find the top 5 softmax probabilities for each image along with each probability and visualizations are provided such as bar charts. For the exact values of predicted probabilities, please see cell N. 24 of the Ipython notebook.
0 - Actual Class 21 [ Double curve ] - Predicted Class: 35 [ Ahead only ]
1 - Actual Class 39 [ Keep left ] - Predicted Class: 39 [ Keep left ]
2 - Actual Class 17 [ No entry ] - Predicted Class: 17 [ No entry ]
3 - Actual Class 17 [ No entry ] - Predicted Class: 17 [ No entry ]
4 - Actual Class 17 [ No entry ] - Predicted Class: 17 [ No entry ]
5 - Actual Class 39 [ Keep left ] - Predicted Class: 39 [ Keep left ]
6 - Actual Class 39 [ Keep left ] - Predicted Class: 39 [ Keep left ]
7 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
8 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
9 - Actual Class 34 [ Turn left ahead ] - Predicted Class: 34 [ Turn left ahead ]
10 - Actual Class 28 [ Children crossing ] - Predicted Class: 28 [ Children crossing ]
11 - Actual Class 39 [ Keep left ] - Predicted Class: 39 [ Keep left ]
12 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 5 [ Speed limit (80km/h) ]
13 - Actual Class 17 [ No entry ] - Predicted Class: 17 [ No entry ]
14 - Actual Class 38 [ Keep right ] - Predicted Class: 38 [ Keep right ]
15 - Actual Class 13 [ Yield ] - Predicted Class: 13 [ Yield ]
16 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
17 - Actual Class 13 [ Yield ] - Predicted Class: 13 [ Yield ]
18 - Actual Class 38 [ Keep right ] - Predicted Class: 38 [ Keep right ]
19 - Actual Class 38 [ Keep right ] - Predicted Class: 38 [ Keep right ]
20 - Actual Class 11 [ Right-of-way at the next intersection ] - Predicted Class: 11 [ Right-of-way at the next intersection ]
21 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 5 [ Speed limit (80km/h) ]
22 - Actual Class 28 [ Children crossing ] - Predicted Class: 28 [ Children crossing ]
23 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 7 [ Speed limit (100km/h) ]
24 - Actual Class 99 [ UNKNOWN ] - Predicted Class: 20 [ Dangerous curve to the right ]
25 - Actual Class 99 [ UNKNOWN ] - Predicted Class: 13 [ Yield ]
26 - Actual Class 99 [ UNKNOWN ] - Predicted Class: 7 [ Speed limit (100km/h) ]
27 - Actual Class 32 [ End of all speed and passing limits ] - Predicted Class: 1 [ Speed limit (30km/h) ]
28 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
29 - Actual Class 28 [ Children crossing ] - Predicted Class: 28 [ Children crossing ]
30 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
31 - Actual Class 40 [ Roundabout mandatory ] - Predicted Class: 40 [ Roundabout mandatory ]
32 - Actual Class 28 [ Children crossing ] - Predicted Class: 28 [ Children crossing ]
33 - Actual Class 24 [ Road narrows on the right ] - Predicted Class: 24 [ Road narrows on the right ]
34 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 0 [ Speed limit (20km/h) ]
35 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 0 [ Speed limit (20km/h) ]
36 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 5 [ Speed limit (80km/h) ]
37 - Actual Class 0 [ Speed limit (20km/h) ] - Predicted Class: 3 [ Speed limit (60km/h) ]
The feature map activations clearly show the outline of the traffic signs, i.e. the CNN finds useful information. Here below you can find the visual output of trained network’s feature maps for a sample of 4 new images imported from the web. For more visual outputs of trained network’s feature maps, please see the cell N. 28 of the Ipython notebook.
0 Original Image
Features right after conv layer 1:
Features right after conv layer 2:
1 Original Image
Features right after conv layer 1:
Features right after conv layer 2:
2 Original Image
Features right after conv layer 1:
Features right after conv layer 2:
3 Original Image
Features right after conv layer 1:
Features right after conv layer 2: